﻿using FCT551.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace FCT551.Views
{
    public delegate void ChangeUniformBackgroudHandler(string msg);

    /// <summary>
    /// OperateView.xaml 的交互逻辑
    /// </summary>
    public partial class OperateView : UserControl
    {
        public OperateView()
        {
            InitializeComponent();
            this.DataContext = new OperaViewModel(this);
            ConfigManageViewModel._ChangeUniform += ChangeUniformGrid;
            HomeViewModel._ChangeUniform += ChangeUniformGrid;
            OperaViewModel.focus += Focus;
        }

        private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
        }

        /// <summary>
        /// 更新产品图片
        /// </summary>
        /// <param name="path"></param>
        public void ChangeUniformGrid(string path)
        {
            //var brush = new ImageBrush
            //{
            //    ImageSource = new BitmapImage(new Uri(path)),
            //    Stretch = Stretch.UniformToFill,
            //    Opacity = 0.7
            //};
            //_UniformGrid.Background = brush;
        }

        /// <summary>
        /// 聚焦二维码框，比较简单，就不在后台逻辑增加
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OperateView_OnLoaded(object sender, RoutedEventArgs e)
        {
            //QRcode.Focus();
        }

        public new void Focus()
        {
            //QRcode.Focus();
        }
    }
}